css: Drop the -gtk-icon-theme property
authorMatthias Clasen <mclasen@redhat.com>
Tue, 21 Apr 2020 12:46:35 +0000 (08:46 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 22 Apr 2020 16:35:30 +0000 (12:35 -0400)
We want to always use the current icon theme, and only
have the minimum amount of custom properties.

14 files changed:
docs/reference/gtk/css-overview.xml
gtk/gtkcssanimatedstyle.c
gtk/gtkcssiconthemevalue.c [deleted file]
gtk/gtkcssiconthemevalueprivate.h [deleted file]
gtk/gtkcssstaticstyle.c
gtk/gtkcssstyle.c
gtk/gtkcssstyleprivate.h
gtk/gtkcssstylepropertyimpl.c
gtk/gtkcsstypesprivate.h
gtk/gtkfilechooserbutton.c
gtk/gtkiconhelper.c
gtk/gtkmountoperation.c
gtk/gtkwindow.c
gtk/meson.build

index 627a2b0e76df7c6815fed8e1e7e68b1713606b08..67f32d6731778efe78f8569bdcbc21b02c2b693e 100644 (file)
@@ -339,7 +339,7 @@ scale[.fine-tune]
         <member><literal>-gtk-icontheme(<replaceable>Name</replaceable>)</literal></member>
       </simplelist>
       The specified icon name is used to look up a themed icon, while taking into
-      account the values of the -gtk-icon-theme and -gtk-icon-palette properties.
+      account the values of the -gtk-icon-palette property.
       This kind of image is mainly used as value of the -gtk-icon-source property. 
     </para>
     <para>
@@ -599,11 +599,6 @@ scale[.fine-tune]
               <entry><ulink url="https://www.w3.org/TR/css-backgrounds-3/#typedef-image">Image</ulink>, <literal>builtin</literal> or <literal>none</literal></entry>
               <entry>used for builtin icons in buttons and expanders</entry>
             </row>
-            <row>
-              <entry>-gtk-icon-theme</entry>
-              <entry>Theme name</entry>
-              <entry>icon theme to use with -gtk-icontheme()</entry>
-            </row>
             <row>
               <entry>-gtk-icon-size</entry>
               <entry><ulink url="https://www.w3.org/TR/css3-values/#length-value">Length</ulink></entry>
index 15745f9b9e2efc70266377d2bc56ffb0567e9fc9..d67bb9f191ea6061b654d81c9e3b2de78e93778d 100644 (file)
@@ -176,10 +176,6 @@ gtk_css_animated_style_set_animated_value (GtkCssAnimatedStyle *animated,
       unshare_core (animated);
       gtk_css_take_value (&style->core->font_size, value);
       break;
-    case GTK_CSS_PROPERTY_ICON_THEME:
-      unshare_core (animated);
-      gtk_css_take_value (&style->core->icon_theme, value);
-      break;
     case GTK_CSS_PROPERTY_ICON_PALETTE:
       unshare_core (animated);
       gtk_css_take_value (&style->core->icon_palette, value);
diff --git a/gtk/gtkcssiconthemevalue.c b/gtk/gtkcssiconthemevalue.c
deleted file mode 100644 (file)
index 0708d84..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-/* GTK - The GIMP Toolkit
- * Copyright (C) 2011 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-
-#include "gtkcssiconthemevalueprivate.h"
-
-#include "gtkicontheme.h"
-#include "gtksettingsprivate.h"
-#include "gtkstyleproviderprivate.h"
-#include "gtkintl.h"
-
-/*
- * The idea behind this value (and the '-gtk-icon-theme' CSS property) is
- * to track changes to the icon theme.
- *
- * We create a new instance of this value whenever the icon theme changes
- * (via emitting the changed signal). So as long as the icon theme does
- * not change, we will compute the same value. We can then compare values
- * by pointer to see if the icon theme changed.
- */
-
-struct _GtkCssValue {
-  GTK_CSS_VALUE_BASE
-  GtkIconTheme *icontheme;
-  guint changed_id;
-};
-
-static void
-gtk_css_value_icon_theme_disconnect_handler (GtkCssValue *value)
-{
-  if (value->changed_id == 0)
-    return;
-
-  g_object_set_data (G_OBJECT (value->icontheme), "-gtk-css-value", NULL);
-
-  g_signal_handler_disconnect (value->icontheme, value->changed_id);
-  value->changed_id = 0;
-}
-
-static void
-gtk_css_value_icon_theme_changed_cb (GtkIconTheme *icontheme,
-                                     GtkCssValue  *value)
-{
-  gtk_css_value_icon_theme_disconnect_handler (value);
-}
-
-static void
-gtk_css_value_icon_theme_free (GtkCssValue *value)
-{
-  gtk_css_value_icon_theme_disconnect_handler (value);
-
-  if (value->icontheme)
-    g_object_unref (value->icontheme);
-
-  g_slice_free (GtkCssValue, value);
-}
-
-static GtkCssValue *
-gtk_css_value_icon_theme_compute (GtkCssValue      *icon_theme,
-                                  guint             property_id,
-                                  GtkStyleProvider *provider,
-                                  GtkCssStyle      *style,
-                                  GtkCssStyle      *parent_style)
-{
-  GtkIconTheme *icontheme;
-
-  if (icon_theme->icontheme)
-    icontheme = icon_theme->icontheme;
-  else
-    icontheme = gtk_icon_theme_get_for_display (_gtk_settings_get_display (gtk_style_provider_get_settings (provider)));
-
-  return gtk_css_icon_theme_value_new (icontheme);
-}
-
-static gboolean
-gtk_css_value_icon_theme_equal (const GtkCssValue *value1,
-                                const GtkCssValue *value2)
-{
-  return FALSE;
-}
-
-static GtkCssValue *
-gtk_css_value_icon_theme_transition (GtkCssValue *start,
-                                     GtkCssValue *end,
-                                     guint        property_id,
-                                     double       progress)
-{
-  return NULL;
-}
-
-static void
-gtk_css_value_icon_theme_print (const GtkCssValue *icon_theme,
-                                GString           *string)
-{
-  g_string_append (string, "initial");
-}
-
-static const GtkCssValueClass GTK_CSS_VALUE_ICON_THEME = {
-  "GtkCssIconThemeValue",
-  gtk_css_value_icon_theme_free,
-  gtk_css_value_icon_theme_compute,
-  gtk_css_value_icon_theme_equal,
-  gtk_css_value_icon_theme_transition,
-  NULL,
-  NULL,
-  gtk_css_value_icon_theme_print
-};
-
-static GtkCssValue default_icon_theme_value = { &GTK_CSS_VALUE_ICON_THEME, 1, FALSE, NULL, 0 };
-
-GtkCssValue *
-gtk_css_icon_theme_value_new (GtkIconTheme *icontheme)
-{
-  GtkCssValue *result;
-
-  if (icontheme == NULL)
-    return _gtk_css_value_ref (&default_icon_theme_value);
-
-  result = g_object_get_data (G_OBJECT (icontheme), "-gtk-css-value");
-  if (result)
-    return _gtk_css_value_ref (result);
-
-  result = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_ICON_THEME);
-  result->icontheme = g_object_ref (icontheme);
-
-  g_object_set_data (G_OBJECT (icontheme), I_("-gtk-css-value"), result);
-  result->changed_id = g_signal_connect (icontheme, "changed", G_CALLBACK (gtk_css_value_icon_theme_changed_cb), result);
-
-  return result;
-}
-
-GtkCssValue *
-gtk_css_icon_theme_value_parse (GtkCssParser *parser)
-{
-  GtkIconTheme *icontheme;
-  GtkCssValue *result;
-  char *s;
-
-  s = gtk_css_parser_consume_string (parser);
-  if (s == NULL)
-    return NULL;
-
-  icontheme = gtk_icon_theme_new ();
-  gtk_icon_theme_set_theme_name (icontheme, s);
-
-  result = gtk_css_icon_theme_value_new (icontheme);
-
-  g_object_unref (icontheme);
-  g_free (s);
-
-  return result;
-}
-
-GtkIconTheme *
-gtk_css_icon_theme_value_get_icon_theme (GtkCssValue *value)
-{
-  g_return_val_if_fail (value->class == &GTK_CSS_VALUE_ICON_THEME, NULL);
-
-  return value->icontheme;
-}
diff --git a/gtk/gtkcssiconthemevalueprivate.h b/gtk/gtkcssiconthemevalueprivate.h
deleted file mode 100644 (file)
index 420d490..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright © 2012 Red Hat Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
- * Authors: Alexander Larsson <alexl@gnome.org>
- */
-
-#ifndef __GTK_CSS_ICON_THEME_VALUE_PRIVATE_H__
-#define __GTK_CSS_ICON_THEME_VALUE_PRIVATE_H__
-
-#include "gtkicontheme.h"
-
-#include "gtkcssparserprivate.h"
-#include "gtkcssvalueprivate.h"
-
-G_BEGIN_DECLS
-
-GtkCssValue *   gtk_css_icon_theme_value_new            (GtkIconTheme           *icontheme);
-
-GtkCssValue *   gtk_css_icon_theme_value_parse          (GtkCssParser           *parser);
-
-GtkIconTheme *  gtk_css_icon_theme_value_get_icon_theme (GtkCssValue            *value);
-
-G_END_DECLS
-
-#endif /* __GTK_CSS_ICON_THEME_VALUE_PRIVATE_H__ */
index fee5c01e560b79682285f5bb4159e5c498ae8a73..d4f7bb5fc75c874a7133600e84d9d7cf7a5b9fbe 100644 (file)
@@ -50,7 +50,6 @@ static const int core_props[] = {
   GTK_CSS_PROPERTY_COLOR,
   GTK_CSS_PROPERTY_DPI,
   GTK_CSS_PROPERTY_FONT_SIZE,
-  GTK_CSS_PROPERTY_ICON_THEME,
   GTK_CSS_PROPERTY_ICON_PALETTE
 };
 
@@ -396,9 +395,6 @@ gtk_css_static_style_set_value (GtkCssStaticStyle *sstyle,
     case GTK_CSS_PROPERTY_FONT_SIZE:
       gtk_css_take_value (&style->core->font_size, value);
       break;
-    case GTK_CSS_PROPERTY_ICON_THEME:
-      gtk_css_take_value (&style->core->icon_theme, value);
-      break;
     case GTK_CSS_PROPERTY_ICON_PALETTE:
       gtk_css_take_value (&style->core->icon_palette, value);
       break;
index 9c570a61a047e2a61e1b26787d77f2acfa523dfd..b02c4dd394fcd479a2aea3be1b4818b77377299f 100644 (file)
@@ -103,8 +103,6 @@ gtk_css_style_get_value (GtkCssStyle *style,
       return style->core->dpi;
     case GTK_CSS_PROPERTY_FONT_SIZE:
       return style->core->font_size;
-    case GTK_CSS_PROPERTY_ICON_THEME:
-      return style->core->icon_theme;
     case GTK_CSS_PROPERTY_ICON_PALETTE:
       return style->core->icon_palette;
     case GTK_CSS_PROPERTY_BACKGROUND_COLOR:
index 1ee874d06b4f756a4670163fa1f7dd18c117e154..65c8c6f700e4988faf014395ed5353a5094b3afb 100644 (file)
@@ -83,7 +83,6 @@ struct _GtkCssCoreValues {
   GtkCssValue *color;
   GtkCssValue *dpi;
   GtkCssValue *font_size;
-  GtkCssValue *icon_theme;
   GtkCssValue *icon_palette;
 };
 
index b27b7730c0ca7f05feeef05fa9894a650674926b..94cd77f6a14c05a4838e24d9279b5a433f162759 100644 (file)
@@ -43,7 +43,6 @@
 #include "gtkcsseasevalueprivate.h"
 #include "gtkcssfiltervalueprivate.h"
 #include "gtkcssfontfeaturesvalueprivate.h"
-#include "gtkcssiconthemevalueprivate.h"
 #include "gtkcssimageprivate.h"
 #include "gtkcssimagevalueprivate.h"
 #include "gtkcssinitialvalueprivate.h"
@@ -794,13 +793,6 @@ background_position_parse (GtkCssStyleProperty *property,
   return _gtk_css_array_value_parse (parser, _gtk_css_position_value_parse);
 }
 
-static GtkCssValue *
-icon_theme_value_parse (GtkCssStyleProperty *property,
-                       GtkCssParser        *parser)
-{
-  return gtk_css_icon_theme_value_parse (parser);
-}
-
 /*** REGISTRATION ***/
 
 G_STATIC_ASSERT (GTK_CSS_PROPERTY_COLOR == 0);
@@ -831,12 +823,6 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_TEXT_SIZE,
                                           font_size_parse,
                                           _gtk_css_font_size_value_new (GTK_CSS_FONT_SIZE_MEDIUM));
-  gtk_css_style_property_register        ("-gtk-icon-theme",
-                                          GTK_CSS_PROPERTY_ICON_THEME,
-                                          GTK_STYLE_PROPERTY_INHERIT,
-                                          GTK_CSS_AFFECTS_ICON_TEXTURE,
-                                          icon_theme_value_parse,
-                                          gtk_css_icon_theme_value_new (NULL));
   gtk_css_style_property_register        ("-gtk-icon-palette",
                                          GTK_CSS_PROPERTY_ICON_PALETTE,
                                          GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_INHERIT,
index 16d4e61f66e854334946df13d238709f315bbf03..e95e31ac9ca88788441d2ab6043b3cda35256dbf 100644 (file)
@@ -188,7 +188,6 @@ enum { /*< skip >*/
   GTK_CSS_PROPERTY_COLOR,
   GTK_CSS_PROPERTY_DPI,
   GTK_CSS_PROPERTY_FONT_SIZE,
-  GTK_CSS_PROPERTY_ICON_THEME,
   GTK_CSS_PROPERTY_ICON_PALETTE,
   GTK_CSS_PROPERTY_BACKGROUND_COLOR,
   GTK_CSS_PROPERTY_FONT_FAMILY,
index b5860d0161976a4eef7216def61ce07d5dfd4613..6f233c89c9c13e6c92459ed66cca532f9353e583 100644 (file)
@@ -272,8 +272,6 @@ static void     gtk_file_chooser_button_root               (GtkWidget *widget);
 static void     gtk_file_chooser_button_map                (GtkWidget        *widget);
 static gboolean gtk_file_chooser_button_mnemonic_activate  (GtkWidget        *widget,
                                                            gboolean          group_cycling);
-static void     gtk_file_chooser_button_css_changed             (GtkWidget              *widget,
-                                                                 GtkCssStyleChange      *change);
 static void     gtk_file_chooser_button_state_flags_changed     (GtkWidget       *widget,
                                                                  GtkStateFlags    previous_state);
 
@@ -467,7 +465,6 @@ gtk_file_chooser_button_class_init (GtkFileChooserButtonClass * class)
   widget_class->show = gtk_file_chooser_button_show;
   widget_class->hide = gtk_file_chooser_button_hide;
   widget_class->map = gtk_file_chooser_button_map;
-  widget_class->css_changed = gtk_file_chooser_button_css_changed;
   widget_class->root = gtk_file_chooser_button_root;
   widget_class->mnemonic_activate = gtk_file_chooser_button_mnemonic_activate;
   widget_class->state_flags_changed = gtk_file_chooser_button_state_flags_changed;
@@ -1346,18 +1343,6 @@ change_icon_theme (GtkFileChooserButton *button)
                NULL);
 }
 
-static void
-gtk_file_chooser_button_css_changed (GtkWidget         *widget,
-                                     GtkCssStyleChange *change)
-{
-  GTK_WIDGET_CLASS (gtk_file_chooser_button_parent_class)->css_changed (widget, change);
-
-  /* We need to update the icon surface, but only in case
-   * the icon theme really changed. */
-  if (!change || gtk_css_style_change_changes_property (change, GTK_CSS_PROPERTY_ICON_THEME))
-    change_icon_theme (GTK_FILE_CHOOSER_BUTTON (widget));
-}
-
 static void
 gtk_file_chooser_button_root (GtkWidget *widget)
 {
index 2bbbcc03549986db753d626cb671e32d6d7f9553..872a30fda3488453724f6052bdb02875e52018c2 100644 (file)
@@ -95,7 +95,7 @@ ensure_paintable_for_gicon (GtkIconHelper    *self,
   GtkIconPaintable *icon;
   GtkIconLookupFlags flags;
 
-  icon_theme = gtk_css_icon_theme_value_get_icon_theme (style->core->icon_theme);
+  icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (self->owner));
   flags = get_icon_lookup_flags (self, style);
   if (preload)
     flags |= GTK_ICON_LOOKUP_PRELOAD;
index a9626ac35e2d507f446e6a6e73399d46068e8866..d1eb782079b2e02b4f103a0527f5bb3235f8193c 100644 (file)
@@ -1206,8 +1206,6 @@ add_pid_to_process_list_store (GtkMountOperation              *mount_operation,
       GtkIconPaintable *icon;
 
       theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (mount_operation->priv->dialog)));
-        (_gtk_style_context_peek_property (gtk_widget_get_style_context (GTK_WIDGET (mount_operation->priv->dialog)),
-                                           GTK_CSS_PROPERTY_ICON_THEME));
       icon = gtk_icon_theme_lookup_icon (theme,
                                          "application-x-executable",
                                          NULL,
index c79f23c15052b66fbf53af82fc17c17817f4c337..ca1688550cfc40d1712fb548b49e0c6e5c47ae1f 100644 (file)
@@ -5731,9 +5731,6 @@ gtk_window_css_changed (GtkWidget         *widget,
 
       update_opaque_region (window, &window_border, &allocation);
     }
-
-  if (change == NULL || gtk_css_style_change_changes_property (change, GTK_CSS_PROPERTY_ICON_THEME))
-    update_themed_icon (window);
 }
 
 /**
index 71fb901e214c3343ec898d10f863076dd3e0ecd7..df08266be0ce83451655c18a6df3e0567c47dbc5 100644 (file)
@@ -55,7 +55,6 @@ gtk_private_sources = files([
   'gtkcssfiltervalue.c',
   'gtkcssfontfeaturesvalue.c',
   'gtkcssfontvariationsvalue.c',
-  'gtkcssiconthemevalue.c',
   'gtkcssimage.c',
   'gtkcssimagecrossfade.c',
   'gtkcssimagefallback.c',